package com.kindness.frate.activity;

import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.kindness.frate.R;
import com.kindness.frate.utils.MySnapHelper;
import com.kindnesslibrary.adapter.CommonAdapter;
import com.kindnesslibrary.adapter.ViewHolder;
import com.kindnesslibrary.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class SnapActivity extends BaseActivity {

    private RecyclerView mRecyclerView;
    private List<Integer> mImagesList;

    @Override
    protected void handlerMessage(Message msg) {

    }

    @Override
    protected int getLayout() {
        return R.layout.activity_snap_layout;
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        mImagesList = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            mImagesList.add(R.mipmap.ic_item1);
            mImagesList.add(R.mipmap.ic_item2);
            mImagesList.add(R.mipmap.ic_item3);
        }
        mRecyclerView = (RecyclerView) findViewById(R.id.rv_main);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
        mRecyclerView.setAdapter(new CommonAdapter<Integer>(this, R.layout.item_view_card, mImagesList){

            @Override
            public void convert(ViewHolder holder, Integer integer) {
                ((ImageView)holder.getView(R.id.imageView)).setImageResource(mImagesList.get(holder.getIndex()));
            }
        });
        MySnapHelper mMySnapHelper = new MySnapHelper();
        mMySnapHelper.attachToRecyclerView(mRecyclerView);
    }

    @Override
    protected void initEvent() {

    }
}
